package com.sairobo.admin.modules.srblive.service.impl;

import java.util.Map;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.sairobo.base.common.entity.Page;
import com.sairobo.base.common.entity.Query;
import com.sairobo.base.common.utils.CommonUtils;
import com.sairobo.admin.modules.srblive.service.SrbliveLiveroomparenttypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sairobo.base.common.entity.R;
import com.sairobo.admin.modules.srblive.entity.SrbliveLiveroomparenttype;
import com.sairobo.admin.modules.srblive.manager.SrbliveLiveroomparenttypeManager;

/**
 * 直播间父类型
 *
 * @author admin
 * @email sairobo
 * @url www.sairobo.com
 * @date 2018年1月11日 下午7:52:34
 */
@Service("srbliveLiveroomparenttypeService")
public class SrbliveLiveroomparenttypeServiceImpl implements SrbliveLiveroomparenttypeService {

	@Autowired
	private SrbliveLiveroomparenttypeManager srbliveLiveroomparenttypeManager;

	@Override
	public Page<SrbliveLiveroomparenttype> listSrbliveLiveroomparenttype(Map<String, Object> params) {
		Query query = new Query(params);
		Page<SrbliveLiveroomparenttype> page = new Page<>(query);
		srbliveLiveroomparenttypeManager.listSrbliveLiveroomparenttype(page, query);
		return page;
	}

	@Override
	public R saveSrbliveLiveroomparenttype(SrbliveLiveroomparenttype role) {
		int count = srbliveLiveroomparenttypeManager.saveSrbliveLiveroomparenttype(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getSrbliveLiveroomparenttypeById(Long id) {
		SrbliveLiveroomparenttype srbliveLiveroomparenttype = srbliveLiveroomparenttypeManager.getSrbliveLiveroomparenttypeById(id);
		return CommonUtils.msg(srbliveLiveroomparenttype);
	}

	@Override
	public R updateSrbliveLiveroomparenttype(SrbliveLiveroomparenttype srbliveLiveroomparenttype) {
		int count = srbliveLiveroomparenttypeManager.updateSrbliveLiveroomparenttype(srbliveLiveroomparenttype);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(Long[] id) {
		int count = srbliveLiveroomparenttypeManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

    @Override
    public R getPtypes(Long pid) {
        EntityWrapper<SrbliveLiveroomparenttype> ew=new EntityWrapper<>();
        ew.orderBy("id");
        if(null!=pid){
            ew.eq("typeId",pid);
        }
        return CommonUtils.msg(srbliveLiveroomparenttypeManager.selectList(ew));
    }

}
